<template>
  <div class="add-subjects">
    <!-- 新增学科弹出层 -->
    <template>
      <el-form :inline="true" class="demo-form-inline">
        <div class="block">
          <strong>所属学科</strong>
          <el-select v-model="selectedRoleId" placeholder="请选择">
            <el-option v-for="(item,index) in list" :key="index" :label="item.label" :value="item.value"> </el-option>
          </el-select>
        </div>
        <el-form-item label="学科名称">
          <el-input v-model="directoryName"></el-input>
        </el-form-item>
      </el-form>
    </template>
    <div class="btn">
      <span slot="footer" class="dialog-footer">
        <el-button @click="$emit('close')">取 消</el-button>
        <el-button type="primary" @click="add">确 定</el-button>
      </span>
    </div>

    <!-- 新增学科弹出层 -->
  </div>
</template>
<script>
import { add } from '@/api/hmmm/directorys'
export default {
  naem: 'tagsAdd',
  props: {
    list: {
      type: Array,
      required: true
    }
  },
  data () {
    return {
      isdisplay: true,
      directoryName: this.channe,
      isaddshow: false,
      // 学科ID
      subjectID: '',
      // 标签名称
      tagName: '',

      // 已经选中的角色ID值
      selectedRoleId: ''
    }
  },
  created () {
    console.log(this.channe)
  },
  methods: {
    async add () {
      const res = await add({
        subjectID: this.selectedRoleId,
        directoryName: this.directoryName
      })
      console.log(res)
      if (res.status !== 200) {
        this.$message.error('操作失败')
      }
      this.$message.success('添加成功')
      this.$emit('closeDialog')
    }
  }
}
</script>

<style scoped lang='scss'>
.btn {
  margin: 20px;
}
</style>
